import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class server {

    private static int listenPort = 4545;


    public static void main(String[] args) {
        //设置swing皮肤
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ServerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ServerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ServerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ServerJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */


        //线程调用ui ， 防止阻塞
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ServerJFrame().setVisible(true);
            }
        });


        //启动服务器
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(listenPort);
            Socket socket = serverSocket.accept();
            new ServerMessageHandleThread(socket).start();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
